﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace miniBoxClassLibrary
{
    public class VerifyCode
    {
        private APUtil.clsDataSrc oDataSrc;
        private APUtil.clsLog oLog = new APUtil.clsLog();
       
        /// <summary>
        /// 產生驗證碼/密碼
        /// </summary>
        /// <returns></returns>
        public string CheckCode(int len)
        {
            int number;
            char code;
            string checkCode = string.Empty;
            Random random = new Random();
            for (int i = 0; i < len; i++)
            {
                number = random.Next();
                if (number % 2 == 0)
                {
                    code = (char)('0' + (char)(number % 10));//產生0--9的數位
                }
                else
                {
                    code = (char)('A' + (char)(number % 26));//產生A--Z的字母
                }
                checkCode += code.ToString();
            }
            return checkCode;
        }
    }
}
